<?php
/*
+-----------------------------------------------------------------------------+
| $Id: *.php,v 1.* 2005/07/01 06:15:08 Bleakwind Exp $
| SnowStats
|         --- A Web Statistics Analysis for multiuser
| Copyright (c) 2003-2005 Weaverdream.com By Bleakwind
| http://www.weaverdream.com
+-----------------------------------------------------------------------------+
*/

include_once 'include/include.php';
check_adminlogin();
include_once 'include/header.php';
?>

<table width="760" border="0" cellpadding="0" cellspacing="0" bgcolor="#5E94DD" align="center">
  <tr bgcolor="#5E94DD">
    <td width="200" align="center" valign="top" class="left_bg">
      <?include_once 'include/menu.php';?>
	</td>
	<td width="560" bgcolor="#FFFFFF" valign="top">

<?php

if(empty($_GET['act'])){

if(empty($_GET['page']) || $_GET['page'] <= 0){$page = 1;}else{$page = (int)$_GET['page'];}
$perpage      = 20;// How many record Paginal
$record_first = $perpage * ($page - 1);// First record of current page
$file_list     = return_dir($SETTING['dir_data']);
$total_record = count($file_list);

if($total_record == 0){
    header("location:prompt.php?act=failed&url=help.php?act=terms&ret=".htmlentities(urlencode($LANGUAGE['admin_user_register']))."&mes=".htmlentities(urlencode($LANGUAGE['admin_user_need_register'])));
}
?>

<table width="100%" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#EBE9ED"><tr><td><img src="images/arrowright.gif" border=0 align="absmiddle"> <a href="index.php" target="_self"><font style="color:#000000;"><?php echo CONFIG_WEBSITE;?></font></a> &raquo; <?php echo $LANGUAGE['admin_user_placedir'];?> &raquo; <?php echo $LANGUAGE['admin_user_place'];?></td></tr></table>
<br>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align="center">
<tr align="right"><td><?php echo sprintf($LANGUAGE['admin_user_totaluser'],"<span class=\"salient\">".$total_record."</span>");?></td></tr>
</table>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#FFFFFF">
<tr align="center" bgcolor="#5E94DD">
  <td width="25%" class="right_title"><?php echo $LANGUAGE['admin_user_user'];?></td>
  <td width="30%" class="right_title"><?php echo $LANGUAGE['admin_user_website'];?></td>
  <td width="15%" nowrap class="right_title"><?php echo $LANGUAGE['admin_user_begindate'];?></td>
  <td width="20%" nowrap class="right_title"><?php echo $LANGUAGE['admin_user_click_perday_ip_pv'];?></td>
  <td width="5%" nowrap class="right_title"><?php echo $LANGUAGE['admin_user_email'];?></td>
  <td width="5%" nowrap class="right_title"><?php echo $LANGUAGE['admin_user_del'];?></td>
</tr>

<?php
for($i=0;$i<$perpage;$i++){
   $record_now = $record_first+$i;
   if($record_now < $total_record){
       $file_config     = $SETTING['dir_data'].$file_list[$record_now].'/'.$SETTING['file_config'];
       $file_click      = $SETTING['dir_data'].$file_list[$record_now].'/'.$SETTING['file_click'];

       include $file_config;
       $begintime       = $CONFIGUSER['begintime'] + $CONFIGUSER['timediff'];
       $totalday        = time_margin($begintime,$TIMENOW['time'],86400);// How many day
       $begindate       = date('Y-m-d',$begintime);// Web intro

       $click           = read_click($file_click,$array_click);
       $click_total_ip  = $click['ip'][0];// Total ip
       $click_total_pv  = $click['pv'][0];// Total pv
       $click_perday_ip = (int)ceil($click_total_ip/$totalday);// Every day ip
       $click_perday_pv = (int)ceil($click_total_pv/$totalday);// Every day pv

       echo "<tr align='center' bgcolor=#EBE9ED>";
       echo "<td class='right_subject'><a href='login.php?user=".$file_list[$record_now]."' title='".$file_list[$record_now]."' class='link2'>".str_encode(bite_str(str_decode($file_list[$record_now]),1,16))."</a></td>";
       echo "<td><a href='".$CONFIGUSER['weburl']."' target='_blank' title='".$CONFIGUSER['website']."\n".$CONFIGUSER['webintro']."'>".str_encode(bite_str(str_decode($CONFIGUSER['website']),1,20))."</a></td>";
       echo "<td nowrap>".$begindate."</td>";
       echo "<td nowrap>".$click_perday_ip."/".$click_perday_pv."</td>";
       echo "<td nowrap><a href='mailto:".$CONFIGUSER['email']."'><img src='images/mail.gif' border='0' title='".sprintf($LANGUAGE['admin_user_mailto'],$CONFIGUSER['email'])."'></a></td>";
       echo "<td nowrap><a href='admin_user.php?act=del&user=".$file_list[$record_now]."'><img src='images/del.gif' border='0' title='".sprintf($LANGUAGE['admin_user_deluser'],$file_list[$record_now])."' onClick=\"return confirm('".$LANGUAGE['admin_user_deluser_confirm']."')\"></a></td>";
       echo "</tr>";

   }
}

echo "<tr align='center' bgcolor='#5E94DD'><td height='20' colspan='7' align='right'>";
pagination("admin_user.php?",$total_record,$perpage);
echo "</td></tr></table>";

}elseif($_GET['act'] == "del") {

if(!is_dir($SETTING['dir_data'].$_GET['user'])){
      header("location:prompt.php?act=failed&mes=".htmlentities(urlencode($LANGUAGE['admin_user_no_user'])));
      exit;
}

$ifok          = "yes";
$file_list = return_dir($SETTING['dir_data'].$_GET['user']."/");
$user_number   = count($file_list);
?>

<table width="100%" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#EBE9ED"><tr><td><img src="images/arrowright.gif" border=0 align="absmiddle"> <a href="index.php" target="_self"><font style="color:#000000;"><?php echo CONFIG_WEBSITE;?></font></a> &raquo; <?php echo $LANGUAGE['admin_user_placedir'];?> &raquo; <?php echo $LANGUAGE['admin_user_place'];?></td></tr></table>
<br>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#FFFFFF">
<tr><td height="25" bgcolor="#EBE9ED">

<?php
for($i=0;$i<$user_number;$i++){
   if (unlink($SETTING['dir_data'].$_GET['user']."/".$file_list[$i])){
       echo "&raquo; ".$_GET['user']."/".$file_list[$i]." ...... <font class=\"succeed\">".$LANGUAGE['admin_user_del_succeed']."</font><br>";
   }else{
       echo "&raquo; ".$_GET['user']."/".$file_list[$i]." ...... <font class=\"failed\">".$LANGUAGE['admin_user_del_failed']."</font><br>";
       $ifok="no";
   }
}
if(rmdir($SETTING['dir_data'].$_GET['user'])){
    echo "&raquo; ".$_GET['user']."/ ...... <font class=\"succeed\">".$LANGUAGE['admin_user_del_succeed']."</font><br>";
}else{
    echo "&raquo; ".$_GET['user']."/ ...... <font class=\"failed\">".$LANGUAGE['admin_user_del_failed']."</font><br>";
    $ifok="no";
}

if($ifok=="yes"){
   echo "<div align='center'>";
   echo "<hr width='100%' size='1' noshade color='#C0C0C0'>";
   echo "<font class='succeed'>".$LANGUAGE['admin_user_deluser_succeed']."</font><br>";
   echo "<a href='admin_user.php'>".$LANGUAGE['admin_user_return']."</a><br>";
   echo "<hr width='100%' size='1' noshade color='#C0C0C0'>";
   echo "</div>";
}else{
   echo "<div align='center'>";
   echo "<hr width='100%' size='1' noshade color='#C0C0C0'>";
   echo "<font class='failed'>".$LANGUAGE['admin_user_deluser_failed']."</font><br>";
   echo "<a href='admin_user.php'>".$LANGUAGE['admin_user_return']."</a><br>";
   echo "<hr width='100%' size='1' noshade color='#C0C0C0'>";
   echo "</div>";
}
echo "</td></tr></table>";

}

echo "<br></td></tr></table>";
include_once 'include/footer.php';
?>